<template>
	<el-dialog title="预览" :append-to-body="true" :visible.sync="visible" :before-close="close"
	  :close-on-click-modal="false" fullscreen>
      <el-form ref="form" >
		<el-form-item size="mini">
			<el-button type="success" v-print="'#check'">打印</el-button>
		</el-form-item>
      </el-form>
	    <div id="check">
				<table width="320px" border="1px" style="line-height: 20px;">
          <tr>
            <td colspan="4"><h6 style="float: right;">SMP-QA-011-F05-00&nbsp;</h6></td>
          </tr>
          <tr>
            <td colspan="4" style="text-align: center;"><h4>样品标签</h4></td>
          </tr>
         <tr>
            <td width="50px">名称:</td>
            <td>{{this.childDataForm.productName}}</td>
            <td width="65px">规格:</td>
            <td width="80px"><p v-html="this.childDataForm.productSpec"></p></td>
          </tr>
          <tr>
            <td>批号:</td>
            <td>{{this.childDataForm.batchNum}}</td>
            <td>样品来源:</td>
            <td>{{this.childDataForm.registCheckDepartmentName}}</td>
          </tr>
          <tr>
            <td>取样量:</td>
            <!-- <td>{{this.childDataForm.getQuantity}}{{this.childDataForm.getUnitName}}</td> -->
			<td></td>
            <td>贮存条件:</td>
            <td>{{this.childDataForm.storageConditions}}</td>
          </tr>
          <tr>
            <td>取样人:</td>
            <td></td>
            <td>取样日期:</td>
            <td></td>
          </tr>
          <tr>
            <td>备注:</td>
            <td colspan="3"></td>
          </tr>
        </table>
			</div>
  </div>
	</el-dialog>
</template>

<script>

  import {
	printProdcutCard
  } from "@/api/print"


  import {
  getCheckInfo
  } from '@/api/check'

  import {
    CODE_OK
  } from '@/common/js/config'

  export default {
    data() {
      return {
        visible: true
      }
    },
    props: ["childDataForm"],
    created() {
		this.view()
    },
    computed:{

      yfb() {
        if (this.childDataForm.checkTypeName == '原料'
        || this.childDataForm.checkTypeName == '独立请验'
        || this.childDataForm.checkTypeName == '辅料'
        || this.childDataForm.checkTypeName == '包材'
        || this.childDataForm.checkTypeName == '其他') {
          return true
        }
        return false
      },
      zc() {
        if (this.childDataForm.checkTypeName == '中间品'
        || this.childDataForm.checkTypeName == '成品') {
          return true
        }
        return false
      }
    },
    methods: {
      view(){
        if (this.yfb) {
          this.childDataForm.content = 'yfb'
        }else if(this.zc){
          this.childDataForm.content = 'zc'
        }
        const params = {
          content: this.childDataForm.content,
          checkId: this.childDataForm.checkId
        }
        getCheckInfo(params).then(res => {
          if (res.code === CODE_OK) {
            this.childDataForm.storageConditions = res.info.list.storageConditions
          }
        });
      },
      close() {
        this.visible = false
        this.$emit('close')
      },
      /**
       * 是否为空字符串，全空格也是空字符串
       * @param str
       * @returns {Boolean}
       */
      isBlank(obj) {
        if (obj == null || typeof obj == "undefined" ||
          obj == "") {
          return true;
        }
        return false;
      }
    }
  }
</script>

<style>
</style>
